package com.linxz.framework.base.presenter;
import com.linxz.framework.base.ActivityLifeCycleEvent;
import com.linxz.framework.base.module.BaseModel;
import com.linxz.framework.base.view.BaseView;
import io.reactivex.subjects.PublishSubject;
/**
 * @author Linxz
 * 创建日期：2019年02月20日 20:29
 * version：1.0.0
 * 描述：
 */
public abstract class BasePresenter<T extends BaseView,M extends BaseModel> {
    public T mView;
    public M mModel;

    public BasePresenter(T mView,PublishSubject<ActivityLifeCycleEvent> lifecycleSubject){
        attachView(mView);
        mModel=createModel(lifecycleSubject);
    }

    public void attachView(T mView){
        this.mView=mView;
    }

    public void detachView(){
        if (mModel!=null){
            mModel.onUnsubscribe();
        }
        this.mView=null;
    }

    public abstract M createModel(PublishSubject<ActivityLifeCycleEvent> lifecycleSubject);

}
